package com.cc.service.Impl;

import com.cc.entity.Book;
import com.cc.mapper.BookMapper;
import com.cc.service.BookService;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


@Service
public class BookServiceImpl implements BookService {

    @Autowired
    BookMapper bookMapper;

//    private static final Logger logger = Logger.getLogger(BookServiceImpl.class.getName());
    @Override
    @Transactional
    public void addBook(String book_name, String author,double price) throws InterruptedException {
        System.out.println("开始书籍保存");
        Book book = new Book();

        book.setBook_name(book_name);
        book.setAuthor(author);
        book.setPublicationdate(new Date());
        book.setPrice((int) price);
        book.setCategory_id(3);
        bookMapper.addBook(book);

        int i = 1 / 0;

    }

    @Override
    public void updateBookById(String book_name, String author, double price, int book_id) throws InterruptedException {
        System.out.println("实现书籍修改");
    }
}
